package com.huangpeng.designmodel.adapter;

import java.util.Objects;

/**
 * @Author huangpeng
 * @Title audio播放
 * @Package
 * @Date 2020/10/23 18:04
 * @Description audio播放
 * @Version 1.0
 */
public class AudioPlayer implements MediaPlayer {
    protected MediaAdapter mediaAdapter;

    @Override
    public void play(String audioType, String fileName) {
        //默认播放 mp3 音乐文件的内置支持
        if(Objects.equals("mp3",audioType)){
            System.out.println("Playing mp3 file. Name: "+ fileName);
        }else if(Objects.equals("vlc",audioType) || Objects.equals("mp4",audioType)){//mediaAdapter 提供了播放其他文件格式的支持
            mediaAdapter = new MediaAdapter(audioType);
            mediaAdapter.play(audioType,fileName);
        }else{
            System.out.println("Invalid media. "+ audioType + " format not supported");
        }
    }
}
